package com.mes.spc.util;

import com.mes.spc.rule.*;

import java.util.ArrayList;
import java.util.List;

public class Test1 {
    public static void main(String[] args) {
//        ExcelUtil excelUtil = new ExcelUtil();
//        List<String[]> strs = excelUtil.parseExcel(new File("D:/test1.xlsx"));
//        String[] tableHeadArray = strs.get(0);//表头
//        System.out.println(ArrayUtils.toString(tableHeadArray));
//        System.out.println();
//        for(String[] sa:strs){
//            System.out.println(ArrayUtils.toString(sa));
//        }
//        System.out.println(SpcCalUtil.isDouble("2.0.3"));
//        try {
//            List<Map<String, Object>> datas = SPCExcelUtil.exportListMap(new File("D:\\test1.xlsx"));
//            for(Map<String, Object> ma:datas){
//                for(String k:ma.keySet()){
//                    System.out.println(k+"---------"+ma.get(k));
//                }
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        List<SPCCommandbase> result = new ArrayList<SPCCommandbase>();
        /*result.add(SPCCommand.SPCRule1);
        result.add(SPCCommand.SPCRule2);
        result.add(SPCCommand.SPCRule3);
        result.add(SPCCommand.SPCRule4);
        result.add(SPCCommand.SPCRule5);
        result.add(SPCCommand.SPCRule6);
        result.add(SPCCommand.SPCRule7);
        result.add(SPCCommand.SPCRule8);*/
        result.add(new SpcRule1());
        result.add(new SpcRule2());
        result.add(new SpcRule3());
        result.add(new SpcRule4());
        result.add(new SpcRule5());
        result.add(new SpcRule6());
        result.add(new SpcRule7());
        result.add(new SpcRule8());

        double[] sampleAvg = {2.308d,2.137d,1.879d,2.778d,2.119d,3.554d,1.783d,2.0637d,2.736d,2.0997d,2.35d
                ,2.35d,2.35d,2.35d,2.35d,2.35d,2.35d,2.35d,2.35d
                ,2.21d,2.22d,2.23d,2.24d,2.25d,2.26d,2.27d,2.28d
                ,2.29d
        };
        double usl = 0d;
        double lsl = 0d;
        double ucl = 3.254d;
        double lcl = 1.438d;
        double standard = 2.346d;
        double tempUcl = (ucl-lcl)/2d;//临时ucl
        double tempLcl = -1d*tempUcl;//临时lcl
        SPCDetermineMethod method = new SPCDetermineMethod(usl,lsl,tempUcl, tempLcl,standard,result);
        for(double s:sampleAvg){
            List<SPCCommandbase> rs = method.Excute(s);
            System.out.println("检测值："+s);
            for(SPCCommandbase spccd:rs){
                System.out.println("检测值："+s+"---"+spccd.getTitle()+"---"+spccd.toString());
            }
            System.out.println("-------------------------");
        }
        
        String ss = "180708WA21NB100767";
        
        System.out.println(ss.substring(ss.length()-6,ss.length()-4));
        System.out.println(ss.substring(ss.length()-7,ss.length()-6));
    }
}
